package com.leap.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leap.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CommentMapper extends BaseMapper<Comment> {

    @Select("SELECT * FROM comment WHERE answer_id = #{commentId}")
    List<Comment> selectChildrenById(Long commentId);

    @Update("UPDATE comment SET like_count = like_count + 1 WHERE id = #{commentId}")
    void addOneLikeCount(Long commentId);

    @Update("UPDATE comment SET like_count = like_count - 1 WHERE id = #{commentId}")
    void minusOneLikeCount(Long commentId);


}
